Skip to content

#2178: Make Release commandlet build-tool independent - #2302

Merged
hohwille merged 13 commits into
devonfw:mainfrom
laert-ll:feature/2178-make-release-commandlet-independent-of-specific-build-commandlet
Sep 4, 2026
Merged

hohwille merged 13 commits into
devonfw:mainfrom
laert-ll:feature/2178-make-release-commandlet-independent-of-specific-build-commandlet

Conversation

@laert-ll

@laert-ll laert-ll commented Aug 11, 2026

Copy link
Copy Markdown
Contributor

This PR fixes #2178

Implemented changes:

  • Release Commandlet is now build-tool independent: it detecs the build tool from its build descriptor (like BuildCommandlet) and works througth the BuildTool interface instead of hardcoding Maven.
  • Build Tool detection now in BuildCommandlet.findBuildCommandlet(...) with priority-ordered first-match, so yarn wins over npm when a yarn.lock is present.
  • Top-level-project check is now based on the build descriptor rather than a hardcoded pom.xml.

Testing instructions

  1. Run the tests in the cli module: mvn -Dtest=BuildCommandletTest,ReleaseCommandletTest test.
  2. In a Maven project (.mvn/maven.config with -Drevision=…-SNAPSHOT), run ide release and check the workflow is as described in #1594: Implement release commandlet #2023.
  3. In a project with no supported build descriptor (or a Gradle-only project), run ide release and check that it fails with "Could not find a supported build tool…".

Checklist for this PR

Make sure everything is checked before merging this PR. For further info please also see
our DoD.

  • When running mvn clean test locally all tests pass and build is successful
  • PR title is of the form #«issue-id»: «brief summary» (e.g. #921: fixed setup.bat and not feature/921 fixed setup.bat). If no issue ID exists, title only.
  • PR top-level comment summaries what has been done and contains link to addressed issue(s)
  • PR and issue(s) have suitable labels
  • Issue is set to In Progress and assigned to you or there is no issue (might happen for very small PRs)
  • You followed all coding conventions
  • You have added the issue implemented by your PR in CHANGELOG.adoc unless issue is labelled
    with internal
  • You have not changed any dependency in pom.xml files or otherwise if runtime dependencies changed, you have updated our LICENSE.asciidoc
  • You have formulated clear instructions on how to test your contribution under "Testing instructions"

@coveralls

coveralls commented Aug 11, 2026

Copy link
Copy Markdown
Collaborator

Coverage Report for CI Build 33897948638

Coverage increased (+0.03%) to 73.907%

Details

  • Coverage increased (+0.03%) from the base build.
  • Patch coverage: No coverable lines changed in this PR.
  • 20 coverage regressions across 3 files.

Uncovered Changes

No uncovered changes found.

Coverage Regressions

20 previously-covered lines in 3 files lost coverage.

File Lines Losing Coverage Coverage
com/devonfw/tools/ide/commandlet/ReleaseCommandlet.java 11 66.67%
com/devonfw/tools/ide/commandlet/CommandletManagerImpl.java 6 91.74%
com/devonfw/tools/ide/commandlet/CommandletManager.java 3 75.0%

Coverage Stats

Coverage Status
Relevant Lines: 18700
Covered Lines: 14443
Line Coverage: 77.24%
Relevant Branches: 8334
Covered Branches: 5537
Branch Coverage: 66.44%
Branches in Coverage %: Yes
Coverage Strength: 3.29 hits per line

💛 - Coveralls

@laert-ll
laert-ll marked this pull request as ready for review August 11, 2026 06:39
@laert-ll laert-ll moved this from 🆕 New to Team Review in IDEasy board Aug 11, 2026
@laert-ll laert-ll self-assigned this Aug 11, 2026
@laert-ll laert-ll changed the title #2178: Initial implementation #2178: Make Release commandlet build-tool independent Aug 11, 2026
@krystynaShatkovska
krystynaShatkovska self-requested a review August 11, 2026 10:14
@krystynaShatkovska krystynaShatkovska self-assigned this Aug 12, 2026

@maybeec maybeec left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for picking this up 👍 — and thanks especially for not stopping at the literal ask. Turning the detection loop from last match wins into first match wins (BuildCommandlet#findBuildCommandlet) quietly fixes two real bugs that were sitting in BuildCommandlet:

  • In a yarn project (package.json + yarn.lock) the old loop had no break, so after Yarn matched it kept going and Npm — last in BUILD_TOOLS — always took over. Yarn.findBuildDescriptor was effectively unreachable.
  • Worse, in a polyglot repo (pom.xml and package.json) the old code ran npm but resolved the defaults from MVN_BUILD_OPTS, i.e. it executed npm clean install. Hoisting the args.isEmpty() block out of the loop fixes that too.

Also good: the parent == null guard in isTopLevelProject — the old projectPath.getParent().resolve("pom.xml") would have thrown a raw NPE when releasing from a filesystem root.

No blockers. The instanceof BuildTool gate is the right shape, CliException is the correct exception type here (expected, user-facing abort), no public signature was broken, and the tests stay inside target. A few things I'd like to see before merge:

Should-fix

  1. ReleaseCommandlet:45-48 — the error message collapses "no build descriptor at all" and "build tool found but it cannot release" into one text. A Gradle user gets told nothing useful.
  2. BuildCommandlet:73 — the new detection is a package-private static that ReleaseCommandlet reaches across into, and it takes an IdeContext parameter although both callers already have this.context. The issue itself points at the better home: "Ideally we should ask the commandlet manager".
  3. BuildCommandlet:75findBuildCommandlet NPEs on a null path; BuildCommandlet guards before calling, ReleaseCommandlet does not.
  4. BuildCommandletTest:142 — the yarn-over-npm fix is the user-visible part of this PR but is only covered at helper level; no test asserts that ide build in the yarn workspace actually runs yarn, and nothing covers the mvn-vs-npm precedence flip.

Minor

  1. ReleaseCommandlet:106 — first condition is always true at the only call site.
  2. ReleaseCommandlet:102 — parameter named buildTool but typed LocalToolCommandlet, while doRun has a different variable also called buildTool.
  3. BuildCommandlet:55 — error message still hardcodes the descriptor list that this PR is de-hardcoding.
  4. CHANGELOG.adoc:9 — the ide build precedence fix is user-facing and not mentioned.

PR hygiene

  • The branch is BEHIND main and needs an update before merge.
  • The checklist ticks "PR and issue(s) have suitable labels", but this PR carries no labels and no milestone. Per DoD.adoc both should be set before close (the issue itself is labelled fine).

Manual verification

Green CI is not sufficient for this one. ide release drives git commit/git tag/git push and a real deploy build — none of which the mock GitContextImplMock exercises end-to-end. Please do run your own testing instructions (2) and (3) on a real Maven project before merge, and note the result in the PR.

Scope against #2178: the primary ask ("ReleaseCommandlet should ask the available build commandlets if they apply") is met. The Additional context part — discovering build commandlets dynamically via the commandlet manager and expressing the yarn/npm priority without a hardcoded list — is not addressed; BUILD_TOOLS is untouched. That is explicitly framed as "ideally" in the issue, so I am not blocking on it, but please say in the PR whether you consider it out of scope so it can be tracked as a follow-up rather than silently dropped.

Comment thread cli/src/main/java/com/devonfw/tools/ide/commandlet/ReleaseCommandlet.java Outdated
Comment thread cli/src/main/java/com/devonfw/tools/ide/commandlet/BuildCommandlet.java Outdated
Comment thread cli/src/main/java/com/devonfw/tools/ide/commandlet/BuildCommandlet.java Outdated
Comment thread cli/src/test/java/com/devonfw/tools/ide/commandlet/BuildCommandletTest.java Outdated
Comment thread cli/src/main/java/com/devonfw/tools/ide/commandlet/ReleaseCommandlet.java Outdated
Comment thread cli/src/main/java/com/devonfw/tools/ide/commandlet/ReleaseCommandlet.java Outdated
Comment thread cli/src/main/java/com/devonfw/tools/ide/commandlet/BuildCommandlet.java Outdated
Comment thread CHANGELOG.adoc Outdated
@laert-ll
laert-ll force-pushed the feature/2178-make-release-commandlet-independent-of-specific-build-commandlet branch from 955ebf1 to a99f171 Compare August 17, 2026 07:14
@laert-ll
laert-ll force-pushed the feature/2178-make-release-commandlet-independent-of-specific-build-commandlet branch from d58b8fa to 4a6600b Compare September 3, 2026 06:27
@laert-ll
laert-ll force-pushed the feature/2178-make-release-commandlet-independent-of-specific-build-commandlet branch from 90c463b to 632af8e Compare September 3, 2026 08:10

@hohwille hohwille left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@laert-ll thanks for your PR. This looks great now and is ready for merge. 👍
I will create a follow up to prevent the typing and avoiding the casts.
Update: Done as #2420

@hohwille
hohwille merged commit 6424434 into devonfw:main Sep 4, 2026
4 checks passed
@github-project-automation github-project-automation Bot moved this from 👀 In review to ✅ Done in IDEasy board Sep 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: ✅ Done

Development

Successfully merging this pull request may close these issues.

Make ReleaseCommandlet independent of specific build commandlet

5 participants